package cn.com.blogonline;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class SearchAction extends HttpServlet {
    
	public void init(ServletConfig config) throws ServletException {
    }
    
    /*
     *  处理<GET> 请求方法.
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    	//设置接收信息的字符集
    	request.setCharacterEncoding("UTF-8");
    	//接收浏览器端提交的信息
		String key = request.getParameter("key");
	    HttpSession session = request.getSession(true);
        //利用hibernate查询匹配文章
		DbOperate	db=new DbOperate();
		List articleList=db.getMatchArticles(key);
		session.setAttribute(Constants.ARTICLE_LIST_KEY,articleList);
	    response.sendRedirect("/BlogOnline/searchResult.jsp");
    }
	protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
		// TODO 自动生成方法存根
		this.doGet(arg0,arg1);
	}
    
}


